<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>计算三角行的面积</title>
		<script type="text/javascript">
			function tri() {
				var x = parseInt(document.getElementById("a").value);
				var y = parseInt(document.getElementById("b").value);
				var z = parseInt(document.getElementById("c").value);
				var t;
				var s;
				t = (x + y + z) / 2;
				s = Math.sqrt(t * (t - x) * (t - y) * (t - z));
				if ((x + y) < z || (x + z) < y || (y + z) < x) //是两边之和小于第三边
				{
					alert("无法构成三角形");
				} else {
					alert("面积为：" + s);
				}
			}
		</script>
	</head>
	<body>
		输入三边
		<p>a:
			<input type="text" id="a" />
		</p>
		<p>b:
			<label>
				<input type="text" id="b" />
			</label>
		</p>
		<p>c:
			<label>
				<input type="text" id="c" />
			</label>
		</p>
		<p>
			<label>
				<input type="button" name="Submit" value="计算" onclick="tri()" />
			</label>
		</p>
	</body>
</html>
